package typex

import "fmt"

func PointerX() {
	i, j := 42, 2701

	p := &i         // point to i
	fmt.Println(p)
	fmt.Println(*p) // read i through the pointer
	*p = 21         // set i through the pointer
	fmt.Println(i)  // see the new value of i

	p = &j         // point to j
	*p = *p / 37   // divide j through the pointer
	fmt.Println(j) // see the new value of j
}

func StructX() {
	fmt.Println(Vertex{1, 2})

	v := Vertex{1, 2}
	v.X = 4
	fmt.Println(v.X)



	p := &v

	p.X = 1e9
	fmt.Printf("type p %T\n", p)
	fmt.Printf("type v %T\n", v)
	fmt.Println("p",p)
	fmt.Println("&p",&p)
	fmt.Println("&v",&v)
	fmt.Println("p.X=",p.X)
	fmt.Println("v.X=",v.X)
	fmt.Println(v)
	v.X=888
	fmt.Println(v)

}

type Vertex struct {
	X int
	Y int
}

